//
//  UIBarButtonItem+ExtenSion.m
//  微blog
//
//  Created by Jorn.Wu on 15/8/24.
//  Copyright (c) 2015年 Jorn.Wu(jorn_wza@sina.com). All rights reserved.
//

#import "UIBarButtonItem+Extension.h"
#import "ThemeButton.h"

@implementation UIBarButtonItem (Extension)

+ (instancetype)itemWithTarget:(id)target title:(NSString *)title image:(NSString *)imagename action:(SEL)action{
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    [btn setBackgroundImage:[UIImage imageNamed:imagename] forState:UIControlStateNormal];
    [btn setTitle:title forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:15];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:btn];
    return item;
}

+ (instancetype)themeItemWithTarget:(id)target title:(NSString *)title image:(NSString *)imagename action:(SEL)action{
    ThemeButton *btn = [[ThemeButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    btn.normalImageName = imagename;
    [btn setTitle:title forState:UIControlStateNormal];
    btn.titleLabel.font = [UIFont systemFontOfSize:15];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:btn];
    return item;
}

@end
